package com.ts.api.common.constant.product;

import com.gitee.apanlh.util.base.ArrayUtils;
import com.gitee.apanlh.util.base.CollUtils;

import java.util.List;

/**
 *  主体计划类型
 *
 *  @author Pan
 */
public enum ProductPlanTypeEnum {

    /** 机构计划 */
    ORG(0),
    /** 平台计划 */
    PLATFORM(1),
    /** 特殊计划 */
    SPECIAL(2),
    ;

    /** env */
    private final Integer type;

    /**
     * 构造函数
     *
     * @param type
     */
    private ProductPlanTypeEnum(Integer type) {
        this.type = type;
    }

    public Integer getType() {
        return type;
    }

    public boolean hasType(Integer type) {
        return this.getType().equals(type);
    }

    /**
     *  将枚举转化listInteger
     *
     *  @return List
     */
    public static List<Integer> listPlanToListInt(List<ProductPlanTypeEnum> listProductPlanTypeEnum) {
        List<Integer> list = CollUtils.newArrayList();
        listProductPlanTypeEnum.forEach(planType -> list.add(planType.getType()));
        return list;
    }

    public static ProductPlanTypeEnum getEnum(Integer planType) {
        return ArrayUtils.find(ProductPlanTypeEnum.values(), t -> t.getType().equals(planType));
    }
}
